package fr.univavignon.m1informatique.rgla.is.ui;

import fr.univavignon.m1informatique.rgla.is.PKITest;

/**
 * 
 * @author DRAMSY Christian
 */
public class pkiFrame extends javax.swing.JFrame {

	private PKITest father;

	/** Creates new form pkiFrame */
	public pkiFrame(PKITest father) {
		initComponents();
		this.father = father;
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		pkiLabel = new javax.swing.JLabel();
		collabLabel = new javax.swing.JLabel();
		salaireLabel = new javax.swing.JLabel();
		subtitleLabel = new javax.swing.JLabel();
		validButton = new javax.swing.JButton();
		collabBox = new javax.swing.JComboBox();
		salaireText = new javax.swing.JTextField();
		jScrollPane1 = new javax.swing.JScrollPane();
		resultArea = new javax.swing.JTextArea();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("PKI DRAMSY MOHLI");
		setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

		pkiLabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
		pkiLabel.setText("PKI DRAMSY , MOHLI");

		collabLabel.setText("Collaborateur");

		salaireLabel.setText("Salaire");

		subtitleLabel.setText("Bienvenue");

		validButton.setText("Valider");
		validButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				validate(evt);
			}
		});

		this.salaireText.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				validate(evt);
			}
		});

		resultArea.setColumns(20);
		resultArea.setRows(5);
		jScrollPane1.setViewportView(resultArea);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(
	            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	            .addGroup(layout.createSequentialGroup()
	                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	                    .addGroup(layout.createSequentialGroup()
	                        .addGap(182, 182, 182)
	                        .addComponent(subtitleLabel))
	                    .addGroup(layout.createSequentialGroup()
	                        .addContainerGap()
	                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	                            .addComponent(collabLabel)
	                            .addComponent(salaireLabel))
	                        .addGap(48, 48, 48)
	                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	                            .addComponent(pkiLabel)
	                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
	                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
	                                    .addComponent(validButton)
	                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
	                                        .addComponent(salaireText, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
	                                        .addComponent(collabBox, 0, 118, Short.MAX_VALUE)))
	                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
	                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE)))))
	                .addGap(303, 303, 303))
	        );
	        layout.setVerticalGroup(
	            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	            .addGroup(layout.createSequentialGroup()
	                .addComponent(pkiLabel)
	                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
	                .addComponent(subtitleLabel)
	                .addGap(14, 14, 14)
	                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	                    .addGroup(layout.createSequentialGroup()
	                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
	                            .addComponent(collabLabel)
	                            .addComponent(collabBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
	                        .addGap(18, 18, 18)
	                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
	                            .addComponent(salaireLabel)
	                            .addComponent(salaireText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
	                        .addGap(52, 52, 52)
	                        .addComponent(validButton))
	                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 565, javax.swing.GroupLayout.PREFERRED_SIZE))
	                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
	        );

	        pack();
		this.setLocationRelativeTo(null);
	}// </editor-fold>

	private void validate(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		if (this.collabBox.getSelectedItem() != null) {
			this.resultArea.setText(this.father.processValidate(this.collabBox
					.getSelectedItem().toString(), this.salaireText.getText()));
		} else {
			this.resultArea.setText("Vous n'avez personne sous vos ordre");
		}
	}

	// Variables declaration - do not modify
	private javax.swing.JComboBox collabBox;
	private javax.swing.JLabel collabLabel;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JLabel pkiLabel;
	private javax.swing.JTextArea resultArea;
	private javax.swing.JLabel salaireLabel;
	private javax.swing.JTextField salaireText;
	private javax.swing.JLabel subtitleLabel;
	private javax.swing.JButton validButton;

	// End of variables declaration

	public javax.swing.JLabel getSubtitleLabel() {
		return subtitleLabel;
	}

	public javax.swing.JComboBox getCollabBox() {
		return collabBox;
	}

	public void setCollabBox(javax.swing.JComboBox collabBox) {
		this.collabBox = collabBox;
	}

}
